package cqrtplm.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ty.basic.util.TyOtype;
import cqrtplm.constant.RTTableTypeConstant;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Data
@Entity
@Table(name = "rt_doc_online_annotation")
@TyOtype(
        displayName = RTTableTypeConstant.TYPE_ONLINE_ANNOTATION
)
public class OnlineAnnotationDO {
    @Id
    private String oid;
    @TyOtype(
            name = RTTableTypeConstant.TYPE_ONLINE_ANNOTATION
    )
    private String otype = RTTableTypeConstant.TYPE_ONLINE_ANNOTATION;

    private Date createstamp;
    private Date updatestamp;
    private Date modifystamp;
    private Long updatecount;
    private Long markfordelete;
    @TableField(value = "creator_full_name")
    private String creatorFullName;

    @TableField(value = "creator_oid")
    private String creatorOid;

    @TableField(value = "img_id")
    private String imgId;

    @TableField(value = "file_ids")
    private String fileIds;
    /**
     * 描述 / 批注内容
     */
    private String description;
    /**
     * 数模轻量化 OID
     */
    private String boid;
    /**
     * 数模轻量化 Otype
     */
    private String botype;

    public OnlineAnnotationDO() {
    }

    public static void fillCommonFieldForUpdate(OnlineAnnotationDO entityBaseDO, Date date) {
        entityBaseDO.setUpdatestamp(date);
        entityBaseDO.setModifystamp(date);
        if (entityBaseDO.getUpdatecount() == null) {
            entityBaseDO.setUpdatecount(0L);
        }

        entityBaseDO.setUpdatecount(entityBaseDO.getUpdatecount() + 1L);
    }

    public static void fillCommonFieldForCreate(OnlineAnnotationDO entityBaseDO, Date date) {
        entityBaseDO.setCreatestamp(date);
        entityBaseDO.setUpdatestamp(date);
        entityBaseDO.setModifystamp(date);
        entityBaseDO.setUpdatecount(0L);
        entityBaseDO.setMarkfordelete(0L);
    }
}
